<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JSON</title>
</head>
<body>
<script type="text/javascript">
    //编写一个js的对象
    var user={
        name :"秦琴",
        age :19,
        sex:"女"
    };
    //将js对象转换成json字符串
    var str=JSON.stringify(user);
    console.log(str);
    //将json字符串转换为js对象
    var user2=JSON.parse(str);
    console.log(user2.name,user2.age,user2.sex);
</script>
</body>
</html>
